Ansible @ an efficient configuration management tool-Ansible configure management-translation (10), ansible-ansibleNo written permission. Do not reprint it
Custom ModulesUntil now we have been working solely with the tools provided to us by Ansible.This does afford us a lot of power, and make many things possible. However, if youhave something particularly compl
Ansible @ an efficient configuration management tool-Ansible configure management-translation (4), ansible-ansibleDo not reprint without written permission
Due to the long content in Chapter 3, I will divide it into several parts for translation.
Advanced PlaybooksSo far the playbooks that we have looked at are simple and just run a number ofmodules in order.
Ansible @ an efficient configuration management tool-Ansible configure management-translation (8), ansible-ansibleIf you do not have written authorization, do not repeat Chapter 4. Use of Ansible in large projects
RolesIf your playbooks start expanding beyond what includes can help you solve, or youstart gathering a l
: indicates that the key storage path is $ {USER}/. ssh/id_dsa.
6> copy the public key on 250 to the controlled client.
# Ssh-copy-id-I ~ /. Ssh/id_rsa.pub root@192.168.1.251Option-I: Specify the Public Key File
# Try to log on without a password in ssh 192.168.1.6.2
7> 250 basic ANSIBEL Test
# Ansible storm_cluster-m command-a 'uptime'
Note: during the first running, you need to enter "yes" for public key verification. You do not need to enter it a
Ansible @ an efficient configuration management tool-Ansible configure management-translation (5), ansible-ansibleDo not reprint advanced Playbook without written permission
Extra variablesYou may have seen in our template example in the previous chapter that we used avariable called group_names . This is one of the magic variables that are provided byAnsible it
configure SSH trust, otherwise you will be prompted to enter the password.ssh-keygen -t rsa //生成密钥[[emailprotected] ~]# ls .ssh/id_rsa id_rsa.pubssh-copy-id -i ~/.ssh/id_rsa.pub [emailprotected](需要免密的受控端ip)Ansible How to get helpAnsible to obtain help information through the Ansible-doc command, you can use the-s option of this command to get help for the specified module//查询
First, installation$ pip Install Ansible#for Debian$ sudo apt-add-repository ppa:rquillo/ansible$ sudo apt-get update$ sudo apt-get install ansible#for CentOS$ sudo yum install ansibleIi. Environmental Notes1. Control host is native2. The controlled end is the LAN 192.168.1.53. SSH key authenticationThird, the use#内建的 Ping
, May 3 2017, 07:55:04) [GCC 4.8.5 20150623 (Red Hat 4.8.5-14)]
7.ansible How to get helpAnsible to obtain help information through the Ansible-doc command, you can use the-s option of this command to obtain help for the specified module.Querying the Help documentation for the ping module[[emailprotected] ~]# ansible
this particular line if set to NO/FA Lse.6. Verify by password, add-k parameter#提供了三种方式: A password is added to the Hosts file, one is a key-free method, one is to use the-K method to manually enter the password, often used for temporary testing.[Email protected] ansible]# ansible all-m ping-kSSH Password:192.168.10.192 | Success >> {"Changed": false,"
roles specified by galaxy to the local device; 5 List: List locally downloaded roles; 6 remove: delete locally downloaded roles.2.3 ansible-pull
Ansible uses the push mode by default. The ansible-pull command can be used in another work mode, namely the PULL mode. It is usually applicable to the following scenarios:
A large number of machines need to be configur
': result = GetHost (CSVFile, sys.argv[2]) print JSON.D Umps (Result)You can now use this inventory script to provide the inventory when using ANSIBLE.A quick-to-test that everything is W Orking correctly is to use the Ping module totest the connection to all the machines. This command won't test whether the hostsare in the right groups; If you want to does, you can use the same ping Modulecommand but inst
.[[emailprotected] ~]# ansible mysql -m copy -a ‘content="Hell Word" dest=/tmp/fstab.ansible‘192.168.154.133 | CHANGED => { "changed": true[[emailprotected] ~]# ansible mysql -a ‘cat /tmp/fstab.ansible‘192.168.154.133 | CHANGED | rc=0 >>Hell WordFile module
Use the file module in Ansible to set the properties of the files. It uses path to specify the
.comThe parameters of the inventory file can be viewed in the Ansible official documentation, below we look at an example of a host file in the official documentation and what each line means.#给some_host主机定义了ssh连接的端口号和用户名some_host ansible_ssh_port=2222 ansible_ssh_user=manager#连接aws_host主机时将通过以下定义的私钥文件进行验证aws_host ansible_ssh_private_key_file=/home/example/.ssh/aws.pem#给freebasd_host主机指定了python的路径freebsd_host ansible_python_i
reboot restart2, the configuration of Node 2, modify the host name:[[Email protected] ~]# service iptables stop[Email protected] ~]# chkconfig iptables off[Email protected] ~]# hostname node2.server.com[Email protected] ~]# vim/etc/sysconfig/networkAdd the following content:Networking=yesHostname=node2.server.comLogout Logout or reboot restartOn the ansible server configuration:
Firewall and Host name configuration
[[Email protected] ~]
‘cat /opt/fstab.bk‘ //查看文件内容# ansible node3 -m copy -a ‘content="HELLO ansible" dest=/opt/fstab.bk‘ //在fstab.bk文件中写入HELLO ansible# ansible node3 -a ‘cat /opt/fstab.bk‘ //查看内容The 6.file module Filem module is used to set file properties. It uses path to specify the file path, uses SRC to define the original file path,
I. Preparation of the first order
Ansible installation is complete, below learn how to use ansible.Just like learning a programming language, first write a Hello World sample program. We also write a ansible "Hello World":
Ansible 192.168.128.83-m Ping
This command means ping
displayed in brief formCommon modules: command, user, copy, cron, file, filesystem, group, hostname, Ping, yumService, Shell, scriptCommand module does not support shell variables and pipelines, etc., if you want to use the shell to execute, you should call the shell module⑵ansible: Performing TasksAnsible -M Module_name: Specifies the called module-A args: Specifies the parameters passed to the module-F #
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.